function copyAddress(){
	if($("#sameaddress").is(":checked")){
		$("#bName").val($("#name").val());
		$("#bAddress1").val($("#address").val());
		$("#bAddress2").val($("#address2").val());
		$("#country2").val($("#country").val());
		print_state('state2',$("#country2")[0].selectedIndex);
		$("#state2").val($("#state").val());
		$("#bCity").val($("#city").val());
		$("#bZipcode").val($("#zipcode").val());
		$("#bPhone").val($("#phone").val());
		$("#bFax").val($("#fax").val());
	}else{
		$("#bName").val("");
		$("#bAddress1").val("");
		$("#bAddress2").val("");
		$("#country2").val("");
		$("#state2").val("");
		$("#bCity").val("");
		$("#bZipcode").val("");
		$("#bPhone").val("");
		$("#bFax").val("");
	}
}

function loadSal(){
	var url = "/popupService";
	var func = "loadSalutation";
	var data = { doClass : func
		}
	simpleservice(url,data,loadSalSuccess);
}

function loadSalSuccess(data){
	var objArray = new Array();
	objArray = JSON.parse(data);
	var opts = objArray.length;
	for ( var i = 0; i < opts; i++) {
		$("#cSal").append( $("<option>").val(objArray[i]["id"]).html(objArray[i]["title"]));	
	}
}

function saveCompanyInfo(){
	var name = $("#name").val();
	var address = $("#address").val();
	var address2 = $("#address2").val();
	var country = $("#country").val();
	var state = $("#state").val();
	var city = 	$("#city").val();
	var zipcode = 	$("#zipcode").val();
	var phone = 	$("#phone").val();
	var fax = 	$("#fax").val();
	var logo = 	$("#logo").val();
	var photo = 	$("#photo").val();
	var website = 	$("#website").val();
	var vatId = 	$("#vatId").val();
	var description = 	$("#description").val();
	var email = 	$("#email").val();
	var offered = 	$("#offered").val();
	
	var bName = 	$("#bName").val();
	var bAddress1 = 	$("#bAddress1").val();
	var bAddress2 = 	$("#bAddress2").val();
	var country2 = 	$("#country2").val();
	var state2 = 	$("#state2").val();
	var bCity = 	$("#bCity").val();
	var bZipcode = 	$("#bZipcode").val();
	var bPhone = 	$("#bPhone").val();
	var bFax = 	$("#bFax").val();
	
	var cSal = 	$("#cSal").val();
	var cName = 	$("#cName").val();
	var cLastname = 	$("#cLastname").val();
	var cDesign = 	$("#cDesign").val();
	var cPhone = 	$("#cPhone").val();
	var cExtn = 	$("#cExtn").val();
	var cFax = 	$("#cFax").val();
	var cEmail = 	$("#cEmail").val();
	var cMobile = 	$("#cMobile").val();
	
	var url = "/hotelinfoService";

	var func = "saveHotelInfo";

	var data = { func : func,
	 name :name,
	 address :address,
	 address2 :address2,
	 country :country,
	 state :state,
	 city :city,
	 zipcode :zipcode,
	 phone :phone,
	 fax :fax,
	 logo :logo,
	 photo :photo,
	 website :website,
	 vatId :vatId,
	 description :description,
	 bName :bName,
	 bAddress1 :bAddress1,
	 bAddress2 :bAddress2,
	 country2 :country2,
	 state2 :state2,
	 bCity :bCity,
	 bZipcode :bZipcode,
	 bPhone :bPhone,
	 bFax :bFax,
	 cSal :cSal,
	 cName :cName,
	 cLastname :cLastname,
	 cDesign :cDesign,
	 cPhone :cPhone,
	 cExtn :cExtn,
	 cFax :cFax,
	 cEmail :cEmail,
	 cMobile : cMobile,
	 email : email,
	 offered : offered
		}
	simpleservice(url,data,saveSuccess);
}

function saveSuccess(data){
	var objArray = new Array();
	if(data!=null){
		objArray = JSON.parse(data);
	}
	var checkLogOut = checkSessionAdmin(objArray);
	if(checkLogOut)
		return;
	simpleDialog("Save Success");
}

function refresh(){
	document.location.href ="/adminconsole/CompanyInfo/hotelinfo.jsp";
}

function edithotelinfo(){
	var url = "/hotelinfoService";

	var func = "getHotelInfo";

	var data = { func : func
		}
	simpleservice(url,data,getsuccess);
}

function getsuccess(data){
	var objArray2 = new Array();
	objArray2 = JSON.parse(data);
	var objArray = objArray2["data"];
	
	if(objArray != null){
		$("#name").val(objArray["name"]);
		$("#address").val(objArray["address"]);
		$("#address2").val(objArray["address2"]);
		$("#country").val(objArray["country"]);
		print_state('state',$("#country")[0].selectedIndex);
		$("#state").val(objArray["state"]);
		$("#city").val(objArray["city"]);
		$("#zipcode").val(objArray["zipcode"]);
		$("#phone").val(objArray["phone"]);
		$("#fax").val(objArray["fax"]);
		$("#logo").val(objArray["logo"]);
		$("#photo").val(objArray["photo"]);
		$("#website").val(objArray["website"]);
		$("#vatId").val(objArray["vatid"]);
		$("#description").val(objArray["descrition"]);
		$("#email").val(objArray["email"]);
		$("#offered").val(objArray["offered"]);
		$("#roomamount").html(objArray2["roomamount"]);
		
		$("#bName").val(objArray["billname"]);
		$("#bAddress1").val(objArray["billaddress"]);
		$("#bAddress2").val(objArray["billaddress2"]);
		$("#country2").val(objArray["billcountry"]);
		print_state('state2',$("#country2")[0].selectedIndex);
		$("#state2").val(objArray["billstate"]);
		$("#bCity").val(objArray["billcity"]);
		$("#bZipcode").val(objArray["billzipcode"]);
		$("#bPhone").val(objArray["billphone"]);
		$("#bFax").val(objArray["billfax"]);
		
		$("#cSal").val(objArray["contactsalutation"]);
		$("#cName").val(objArray["contactfirstname"]);
		$("#cLastname").val(objArray["contactlastname"]);
		$("#cDesign").val(objArray["contactdesignation"]);
		$("#cPhone").val(objArray["contactphone"]);
		$("#cExtn").val(objArray["contactextn"]);
		$("#cFax").val(objArray["contactfax"]);
		$("#cEmail").val(objArray["contactemail"]);
		$("#cMobile").val(objArray["contactmobile"]);
	}

}